
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>仓库 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="branch.html" />
    
    
    <link rel="prev" href="about.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    首页
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="about.html">
            
                <a href="about.html">
            
                    
                    介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3" data-path="repository.html">
            
                <a href="repository.html">
            
                    
                    仓库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="branch.html">
            
                <a href="branch.html">
            
                    
                    分支
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="version.html">
            
                <a href="version.html">
            
                    
                    版本
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="flow.html">
            
                <a href="flow.html">
            
                    
                    流程
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >仓库</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x4ED3;&#x5E93;-repository">&#x4ED3;&#x5E93; Repository</h1>
<blockquote>
<p>&#x5728; Git &#x7684;&#x6982;&#x5FF5;&#x4E2D;&#xFF0C;&#x4ED3;&#x5E93;&#xFF0C;&#x5C31;&#x662F;&#x4F60;&#x5B58;&#x5728;.git&#x76EE;&#x5F55;&#x7684;&#x90A3;&#x4E2A;&#x6587;&#x4EF6;&#x5939;&#x5185;&#x7684;&#x6240;&#x6709;&#x6587;&#x4EF6;&#xFF0C;&#x5305;&#x62EC;&#x9690;&#x85CF;&#x7684;&#x6587;&#x4EF6;&#xFF0C;Git&#x7A0B;&#x5E8F;&#x4F1A;&#x5728;&#x5F53;&#x524D;&#x76EE;&#x5F55;&#x4EE5;&#x53CA;&#x4E0A;&#x7EA7;&#x76EE;&#x5F55;&#x67E5;&#x627E;&#x662F;&#x5426;&#x5B58;&#x5728;.git&#x6587;&#x4EF6;&#xFF0C;&#x5982;&#x679C;&#x5B58;&#x5728;&#xFF0C;&#x5219;&#x4F1A;&#x5C06;.git&#x76EE;&#x5F55;&#x5B58;&#x5728;&#x7684;&#x6587;&#x4EF6;&#x5939;&#x5F00;&#x59CB;&#x4E0B;&#x7684;&#x6240;&#x6709;&#x6587;&#x4EF6;&#x5F53;&#x6210;&#x4F60;&#x9700;&#x8981;&#x7BA1;&#x7406;&#x7684;&#x6587;&#x4EF6;&#xFF0C;&#x6240;&#x4EE5;&#xFF0C;&#x6211;&#x4EEC;&#x5982;&#x679C;&#x60F3;&#x5C06;&#x67D0;&#x4E2A;&#x6587;&#x4EF6;&#x5939;&#x5F53;&#x505A;&#x4E00;&#x4E2A;Git&#x4ED3;&#x5E93;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x5728;&#x90A3;&#x4E2A;&#x6587;&#x4EF6;&#x5939;&#x4E0B;&#x901A;&#x8FC7;&#x7EC8;&#x7AEF;&#x6765;&#x6267;&#x884C;</p>
</blockquote>
<h2 id="&#x521B;&#x5EFA;&#x672C;&#x5730;&#x4ED3;&#x5E93;">&#x521B;&#x5EFA;&#x672C;&#x5730;&#x4ED3;&#x5E93;</h2>
<ul>
<li>&#x9009;&#x62E9;&#x4E00;&#x4E2A;&#x76EE;&#x5F55;&#x4F5C;&#x4E3A;&#x9879;&#x76EE;&#x7684;&#x672C;&#x5730;&#x4ED3;&#x5E93;&#xFF0C;&#x8FDB;&#x5165;&#x8BE5;&#x76EE;&#x5F55;&#x3002;</li>
<li>&#x521D;&#x59CB;&#x5316;&#xFF0C;&#x628A;&#x8FD9;&#x4E2A;&#x76EE;&#x5F55;&#x53D8;&#x6210;Git&#x53EF;&#x4EE5;&#x7BA1;&#x7406;&#x7684;&#x4ED3;&#x5E93;<pre><code class="lang-bash">$ git init
</code></pre>
</li>
<li>&#x521B;&#x5EFA;&#x5E76;&#x7F16;&#x8F91; <code>.gitignore</code><pre><code class="lang-bash"><span class="hljs-comment"># .gitignore &#x5185;&#x5BB9;&#x793A;&#x4F8B;</span>
.DS_Store
node_modules
npm-debug.log
</code></pre>
</li>
<li>&#x628A;&#x65B0;&#x7684;&#x6587;&#x4EF6;&#x64CD;&#x4F5C;&#x8BB0;&#x5F55;&#x6DFB;&#x52A0;&#x5230;&#x6682;&#x5B58;&#x533A;&#xFF08;stage&#xFF09;<pre><code class="lang-bash">$ git add .
$ git add foo.js
</code></pre>
</li>
<li>&#x628A;&#x6682;&#x5B58;&#x533A;&#x7684;&#x6587;&#x4EF6;&#x64CD;&#x4F5C;&#x8BB0;&#x5F55;&#x63D0;&#x4EA4;&#x5230;&#x672C;&#x5730;&#x4ED3;&#x5E93;<pre><code class="lang-bash">$ git commit -m <span class="hljs-string">&apos;create&apos;</span>
</code></pre>
</li>
</ul>
<h2 id="&#x63D0;&#x4EA4;&#x8FDC;&#x7A0B;&#x4ED3;&#x5E93;">&#x63D0;&#x4EA4;&#x8FDC;&#x7A0B;&#x4ED3;&#x5E93;</h2>
<ul>
<li>&#x67E5;&#x770B;&#x672C;&#x5730;&#x4ED3;&#x5E93;&#x5730;&#x5740;&#x5F53;&#x524D;&#x5BF9;&#x5E94;&#x7684;&#x8FDC;&#x7A0B;&#x4ED3;&#x5E93;<pre><code class="lang-bash">$ git remote show origin
</code></pre>
</li>
<li>&#x5148;&#x5728;&#x8FDC;&#x7A0B;&#x670D;&#x52A1;&#x7AEF;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x8FDC;&#x7A0B;&#x4ED3;&#x5E93;&#xFF0C;&#x6BCF;&#x4E2A;&#x8FDC;&#x7A0B;&#x4ED3;&#x5E93;&#x90FD;&#x4F1A;&#x5206;&#x522B;&#x6709;&#x4E00;&#x4E2A;https&#x5730;&#x5740;&#x548C;&#x4E00;&#x4E2A;ssh&#x5730;&#x5740;</li>
<li>&#x8BBE;&#x7F6E;&#x672C;&#x5730;&#x4ED3;&#x5E93;&#x5BF9;&#x5E94;&#x7684;&#x8FDC;&#x7A0B;&#x4ED3;&#x5E93;<pre><code class="lang-bash">$ git remote add origin https://xxx.com/xxx.git
</code></pre>
</li>
<li>&#x4FEE;&#x6539;&#x672C;&#x5730;&#x4ED3;&#x5E93;&#x5BF9;&#x5E94;&#x7684;&#x8FDC;&#x7A0B;&#x4ED3;&#x5E93;<pre><code class="lang-bash">$ git remote <span class="hljs-built_in">set</span>-url origin https://xxx.com/xxx.git
</code></pre>
</li>
<li>&#x628A;&#x672C;&#x5730;&#x4ED3;&#x5E93;&#x7684;&#x5185;&#x5BB9;&#x63A8;&#x9001;&#x5230;&#x8FDC;&#x7A0B;&#x4ED3;&#x5E93;<pre><code class="lang-bash">$ git push origin master
$ git push -u origin master
</code></pre>
</li>
</ul>
<h3 id="1-&#x4F7F;&#x7528;-https">1. &#x4F7F;&#x7528; https</h3>
<ul>
<li>&#x8BBE;&#x7F6E;&#x8D26;&#x6237;<pre><code class="lang-bash">$ git config user.name <span class="hljs-string">&quot;xxx&quot;</span>
$ git config --global user.name <span class="hljs-string">&quot;xxx&quot;</span>
</code></pre>
</li>
<li>&#x8BBE;&#x7F6E;&#x90AE;&#x7BB1;<pre><code class="lang-bash">$ git config user.email <span class="hljs-string">&quot;xxx@gmail.com&quot;</span>
$ git config --global user.email <span class="hljs-string">&quot;xxx@gmail.com&quot;</span>
</code></pre>
</li>
<li>&#x8BBE;&#x7F6E;&#x8BB0;&#x4F4F;&#x5BC6;&#x7801;<pre><code class="lang-bash"><span class="hljs-comment"># &#x9ED8;&#x8BA4;15&#x5206;&#x949F;</span>
$ git config --global credential.helper cache
<span class="hljs-comment"># &#x957F;&#x671F;&#x5B58;&#x50A8;</span>
$ git config --global credential.helper store
<span class="hljs-comment"># &#x589E;&#x52A0;&#x8FDC;&#x7A0B;&#x5730;&#x5740;&#x7684;&#x65F6;&#x5019;&#x5E26;&#x4E0A;&#x5BC6;&#x7801;</span>
$ git remote add origin http://yourname:password@git.github.com/name/project.git
</code></pre>
</li>
<li>https&#x6BCF;&#x6B21;&#x4E0A;&#x4F20;&#x6587;&#x4EF6;&#x5927;&#x5C0F;&#x88AB;&#x9650;&#x5236;&#xFF0C;&#x65E0;&#x6CD5;&#x6EE1;&#x8DB3;&#x5927;&#x6587;&#x4EF6;&#x7684;&#x4E0A;&#x4F20;</li>
</ul>
<h3 id="2-&#x4F7F;&#x7528;-ssh">2. &#x4F7F;&#x7528; ssh</h3>
<ul>
<li>&#x4FEE;&#x6539;&#x672C;&#x5730;&#x4ED3;&#x5E93;&#x5BF9;&#x5E94;&#x7684;&#x8FDC;&#x7A0B;&#x4ED3;&#x5E93;&#xFF0C;&#x6539;&#x4E3A;&#x4F7F;&#x7528;ssh</li>
<li>&#x751F;&#x6210; sshkey<pre><code class="lang-bash">$ ssh-keygen -t rsa -C <span class="hljs-string">&quot;xxx@xxx.com&quot;</span>
<span class="hljs-comment"># &#x4E09;&#x6B21;&#x56DE;&#x8F66;&#x5373;&#x53EF;&#x751F;&#x6210; ssh key</span>
</code></pre>
</li>
<li>&#x67E5;&#x770B;&#x751F;&#x6210;ssh&#x516C;&#x94A5;&#xFF0C;&#x5E76;&#x6DFB;&#x52A0;&#x5230;&#x8FDC;&#x7A0B;&#x540E;&#x53F0;&#x4E2D;<pre><code class="lang-bash">$ cat ~/.ssh/id_rsa.pub
<span class="hljs-comment"># ssh-rsa AAAAB3NzaC1yc2EA...</span>
</code></pre>
</li>
<li>&#x9A8C;&#x8BC1;&#x662F;&#x5426;&#x6DFB;&#x52A0;&#x6210;&#x529F;<pre><code class="lang-bash">$ ssh -T git@github.com
<span class="hljs-comment"># Welcome</span>
</code></pre>
</li>
</ul>
<h2 id="&#x514B;&#x9686;&#x8FDC;&#x7A0B;&#x4ED3;&#x5E93;&#x5230;&#x672C;&#x5730;">&#x514B;&#x9686;&#x8FDC;&#x7A0B;&#x4ED3;&#x5E93;&#x5230;&#x672C;&#x5730;</h2>
<ul>
<li>&#x83B7;&#x53D6;&#x8FDC;&#x7A0B;&#x4ED3;&#x5E93;&#x7684;&#x5730;&#x5740;</li>
<li>&#x514B;&#x9686;&#x8FDC;&#x7A0B;&#x4ED3;&#x5E93;&#x7684;&#x9ED8;&#x8BA4;&#x5206;&#x652F;&#x5230;&#x672C;&#x5730;&#x5E93;<pre><code class="lang-bash">$ git <span class="hljs-built_in">clone</span> https://xxx.com/xxx.git
</code></pre>
</li>
<li>&#x514B;&#x9686;&#x8FDC;&#x7A0B;&#x4ED3;&#x5E93;&#x7684;&#x5236;&#x5B9A;&#x5206;&#x652F;&#x5230;&#x672C;&#x5730;&#x5E93;<pre><code class="lang-bash">$ git <span class="hljs-built_in">clone</span> -b &lt;branch name&gt; https://xxx.com/xxx.git
</code></pre>
</li>
</ul>
<h2 id="&#x540C;&#x6B65;&#x8FDC;&#x7A0B;&#x4ED3;&#x5E93;&#x5230;&#x672C;&#x5730;">&#x540C;&#x6B65;&#x8FDC;&#x7A0B;&#x4ED3;&#x5E93;&#x5230;&#x672C;&#x5730;</h2>
<ul>
<li>&#x5148;&#x4FDD;&#x8BC1;&#x5F53;&#x524D;&#x672C;&#x5730;&#x4ED3;&#x5E93;&#x6682;&#x5B58;&#x533A;&#x662F;&#x5E72;&#x51C0;&#x7684;</li>
<li>&#x540C;&#x6B65;&#x8FDC;&#x7A0B;&#x4ED3;&#x5E93;&#x5230;&#x672C;&#x5730;<pre><code class="lang-bash">$ git pull origin master
<span class="hljs-comment"># or &#x4F7F;&#x7528; git fetch</span>
$ git fetch origin master
$ git diff master..origin/master
$ git merge origin/master
</code></pre>
</li>
</ul>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="about.html" class="navigation navigation-prev " aria-label="Previous page: 介绍">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="branch.html" class="navigation navigation-next " aria-label="Next page: 分支">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"仓库","level":"1.3","depth":1,"next":{"title":"分支","level":"1.4","depth":1,"path":"branch.md","ref":"branch.md","articles":[]},"previous":{"title":"介绍","level":"1.2","depth":1,"path":"about.md","ref":"about.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"repository.md","mtime":"2017-11-29T01:48:11.728Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2017-11-29T01:49:36.040Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

